﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.Admin
{
    public partial class WebForm16 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string id = Request.QueryString["id"];
                if (id == null)
                {
                    Response.Redirect("Hospital.aspx");
                }
                else
                {
                    HospitalInfo hosp = this.dc.HospitalInfos.Single(h => h.hospitalid.Equals(id));
                    this.hospitalname.Value = hosp.hospitalname;
                    this.phoneno.Value = hosp.phoneno;
                    this.location.Value = hosp.location;
                    this.url.Value = hosp.url;
                }
            }
        }

        protected void ButtonUpdate_Click(object sender, EventArgs e)
        {
            string hospitalname = this.hospitalname.Value;
            string phoneno = this.phoneno.Value;
            string location = this.location.Value;
            string url = this.url.Value;
            update(hospitalname, phoneno, location, url);
        }
        public void update(string hospitalname, string phoneno, string location, string url)
        {
            string id = Request.QueryString["id"];
            HospitalInfo hos = this.dc.HospitalInfos.Single(hp => hp.hospitalid.Equals(id));
            hos.hospitalname = hospitalname;
            hos.phoneno = phoneno;
            hos.location = location;
            hos.url = url;
            dc.SubmitChanges();
            this.Labelkq.Text = "Update Successful";
        }
    }
}